class Method{
    // 方法的修饰： private,protected,public 方法默认为public


    // 静态方法
    static def DisplayName(){
        println("This is how methods work in groovy.");
        println("This is an example of a simple method.");
    }

    static def Sum(int a,int b){
        return a + b;
    }

    int x;
    // 实例方法
    def getX(){
        return x;
    }

    def setX(int x){
        this.x = x;
    }

    static void main(String[] args){
        DisplayName();
        println("1 + 2 = "+Sum(1,2));

        var m = new Method();
        m.setX(100);
        println("m.x = "+m.getX());
    }
}